package com.cmsr.hdpf.etl.task.parse

import com.alibaba.fastjson.{JSON, JSONArray, JSONObject}
import com.cmsr.hdpf.model.{RsmDataStream, SuzhouRoadMap}
import org.apache.http.HttpEntity
import org.apache.http.client.methods.{CloseableHttpResponse, HttpGet}
import org.apache.http.impl.client.{CloseableHttpClient, HttpClients}
import org.apache.http.util.EntityUtils

import scala.collection.mutable.{ListBuffer, Map}

//
//object GTRsmParser extends BaseParser {
//    /**
//     * 解析原始的json数据，解析嵌套消息，一条消息中，有交通参与者列表信息participants：List<Participant>
//     *
//     * @param rawJson
//     * @param suzhouRoadMap
//     * @return
//     */
//    override def Parse(rawJson: String): RsmDataStream = {
//
//        // 将string转为object对象，可以通过
//        println("rawJson:",rawJson)
//        val jObject = JSON.parseObject(rawJson) // 将json转为object
//        println("jObject",jObject)
//        val uid = jObject.getString("id")
//        val timestamp: String = jObject.getString("time") // 获取时间戳 单位ms
////        val deviceID = jObject.getJSONArray("time_data").getJSONObject(0).getString("camera_IP") // 设备ID（一条数据只包含一个摄像头的数据？）
//
//        println("转为json对象后，用户id " + uid+ ", " )
//        println("")
//
//        val nums:List[Tuple3[Long,Long,Long]]= List((-1, -1, -1) )
//        val rst = new RsmDataStream(timestamp=timestamp,id=uid,pt_list=nums)
//        rst
//    }
//
//    /**
//     * 处理json消息方法
//     *
//     * @param rawJson 交通参与者列表List<Participant> 是string类型
//     * @return
//     */
////    private def RsmHandle(rawJson: String, deviceID: String): List[RsmDataStream] = {
////
////        var rsmData: ListBuffer[RsmDataStream] = ListBuffer()
////
////        val rsm: List[String] = ListHandle(rawJson)
////        for (participant <- rsm) { // for 循环
////            val p: Map[String, String] = MapHandle(participant) // 解析单个交通参与者信息，返回一个Map
////
////            val lane_id = p("lane_id").toString // 车道 id
////
////            // 一一层一层解析处理！
////            val lane_data: Map[String, String] = MapHandle(p("lane_data"))
////
////            val pos = lane_data("location")
////            val longitude = MapHandle(pos)("longitude").toDouble // 经度
////            val latitude = MapHandle(pos)("latitude").toDouble // 维度
////
////            val speed = lane_data("average_speed").toDouble
////            val flow = lane_data("total_count").toDouble // 不是所有类型车辆数之和？
////
////            val _p = RsmDataStream(
////                timestamp = 0,
////                id = deviceID ,//+ "-" + lane_id,
//////                device_id = deviceID,
//////                lane_id = lane_id,
//////                longitude = longitude,
//////                latitude = latitude,
//////                speed = speed,
//////                flow = flow
////            )
////            rsmData += _p
////
////
////        }
////        rsmData.toList
////    }
//
//}
